﻿using System;
using HT.Framework;
using UnityEngine.UI;

namespace TG
{
    public class TestPanel : HTBehaviour
    {
        public Text vitality;
        public Text countDown;

        public Text needPeach;
        public Text needPumpkin;
        public Text needCabbage;
        public Text needGreenGrass;

        public Text havePeach;
        public Text havePumpkin;
        public Text haveCabbage;
        public Text haveGreenGrass;

        public Text specialItemName;


        public Text curLevel;
        public Text curScore;


        private void Update()
        {
            if (!MainGame.Instance.IsActive) return;

            vitality.text = GameManager.Instance.gameData.vitalityValue.ToString();

            DateTime dateTime = new DateTime();
            var addSeconds = dateTime.AddSeconds(GameManager.Instance.gameData.gameTime);
            countDown.text = addSeconds.ToString("mm:ss");
            curScore.text=GameManager.Instance.gameData.score.ToString();

            if (MainGame.Instance.curGameConfig.gameType != 1)
            {
                if (GameManager.Instance.gameData.gameConfigData.num.Length > 0)
                    needGreenGrass.text = GameManager.Instance.gameData.gameConfigData.num[0].ToString();
                if (GameManager.Instance.gameData.gameConfigData.num.Length > 1)
                    needCabbage.text = GameManager.Instance.gameData.gameConfigData.num[1].ToString();
                if (GameManager.Instance.gameData.gameConfigData.num.Length > 2)
                    needPeach.text = GameManager.Instance.gameData.gameConfigData.num[2].ToString();
                if (GameManager.Instance.gameData.gameConfigData.num.Length > 3)
                    needPumpkin.text = GameManager.Instance.gameData.gameConfigData.num[3].ToString();
            }

            haveGreenGrass.text = GameManager.Instance.gameData.targetDic.ContainsKey(MapItemType.GreenGrass)
                ? GameManager.Instance.gameData.targetDic[MapItemType.GreenGrass].ToString()
                : "0";

            haveCabbage.text = GameManager.Instance.gameData.targetDic.ContainsKey(MapItemType.Cabbage)
                ? GameManager.Instance.gameData.targetDic[MapItemType.Cabbage].ToString()
                : "0";

            havePeach.text = GameManager.Instance.gameData.targetDic.ContainsKey(MapItemType.Peach)
                ? GameManager.Instance.gameData.targetDic[MapItemType.Peach].ToString()
                : "0";

            havePumpkin.text = GameManager.Instance.gameData.targetDic.ContainsKey(MapItemType.Pumpkin)
                ? GameManager.Instance.gameData.targetDic[MapItemType.Pumpkin].ToString()
                : "0";

            if (GameManager.Instance.Player == null) return;

            if (GameManager.Instance.Player.GetVacuumCleaner())
            {
                specialItemName.text = "吸尘器";
            }
            else if (GameManager.Instance.Player.GetCleat())
            {
                specialItemName.text = "钢铁羊角";
            }
            else
            {
                specialItemName.text = "无";
            }

            curLevel.text = GameManager.Instance.gameData.levelID.ToString();
        }
    }
}